<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>  
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
		<title>会员管理</title>
		<link rel="stylesheet" href="<%=basePath %>css/style.default.css" type="text/css" />
		<script type="text/javascript" src="<%=basePath %>js/plugins/jquery-1.7.min.js"></script>
		<script type="text/javascript" src="<%=basePath %>js/plugins/jquery-form.js"></script>
	</head>

	<body class="withvernav">
		<div class="bodywrapper">
			<div class="topheader">
				<div class="left">
					<h1 class="logo">趣味<span>国学</span></h1>
					<br clear="all" />
				</div>
				<!--left-->
				<div class="right">
					<div class="userinfo">
						<img src="<%=basePath %>images/thumbs/avatar.png" alt="" />
						<span>管理员</span>
						<a class="fa fa-power-off transition3" title="退出" href="<%=basePath %>back/logout.do"></a>
					</div>
					<!--userinfo-->
				</div>
				<!--right-->
			</div>
			<!--topheader-->
			<div class="vernav2 iconmenu">
				<ul>
					<li class="current">
						<a href="#formsub" class="editor"><i class="fa fa-flag-checkered"></i>数据配置</a>
						<span class="arrow"></span>
			            	<ul id="formsub" style="display: none;">
						<li>
							<a href="<%=basePath %>View/levelConfig/level.do" class="elements"><i class="fa fa-trophy"></i>闯关配置</a>
						</li>
						<li>
							<a href="<%=basePath %>View/propConfig/prop.do" class="elements"><i class="fa fa-trophy"></i>道具配置</a>
						</li>
						<li>
							<a href="<%=basePath %>View/bookConfig/book.do" class="widgets"><i class="fa fa-book"></i>典籍配置</a>
						</li>
						<li>
							<a href="<%=basePath %>View/planConfig/plan.do" class="calendar"><i class="fa fa-spinner"></i>计划配置</a>
						</li>
						<li>
							<a href="<%=basePath %>View/planChapterConfig/planChapter.do" class="typo"><i class="fa fa-pie-chart"></i>计划章节配置</a>
						</li>
						<li>
							<a href="<%=basePath %>View/tapesConfig/tapes.do" class="support"><i class="fa fa-microphone"></i>录音进度配置</a>
						</li>
						<li>
							<a href="<%=basePath %>View/regionConfig/region.do" class="typo"><i class="fa fa-pie-chart"></i>区域配置</a>
						</li>
						<li>
							<a href="<%=basePath %>View/meanConfig/mean.do" class="tables"><i class="fa fa-file-powerpoint-o"></i>释义配置</a>
						</li>
						<li>
							<a href="<%=basePath %>View/chapterConfig/chapter.do" class="buttons"><i class="fa fa-file-text"></i>章节目录配置</a>
						</li>
						<li>
							<a href="<%=basePath %>View/masterConfig/master.do" class="error"><i class="fa fa-volume-down"></i>专家吟诵</a>
						</li>
						<li>
							<a href="<%=basePath %>View/storyConfig/story.do" class="widgets"><i class="fa fa-book"></i>故事配置</a>
						</li>
						<li>
							<a href="<%=basePath %>View/shopConfig/shopConfig.do" class="error"><i class="fa fa-share"></i>商城配置</a>
						</li>
						<li>
							<a href="<%=basePath %>View/coinsConfig/coinsConfig.do" class="error"><i class="fa fa-share"></i>充值配置</a>
						</li>
			            </ul>
			            </li>
						<li>
							<a href="<%=basePath %>View/materialConfig/material.do" class="error"><i class="fa fa-file-image-o"></i>素材管理</a>
						</li>
						<li>
							<a href="<%=basePath %>View/memberConfig/member.do" class="error"><i class="fa fa-group"></i>会员管理</a>
						</li>
						<li>
							<a href="<%=basePath %>View/publishLogs/publish.do" class="error"><i class="fa fa-share"></i>版本发布</a>
						</li>
						<li>
							<a href="<%=basePath %>View/reportTapes/report.do" class="error"><i class="fa fa-share"></i>作品举报</a>
						</li>
						<li>
							<a href="<%=basePath %>View/feedback/feedback.do" class="error"><i class="fa fa-share"></i>意见反馈</a>
						</li>
						<li>
							<a href="<%=basePath %>View/push/push.do" class="error"><i class="fa fa-share"></i>推送消息</a>
						</li>
				</ul>
				<a class="togglemenu"></a>
				<br /><br />
			</div>
			<!--leftmenu-->
			<div class="centercontent">
				<div class="add floatClear">
					<div class="contenttitle2 floatLeft">
						<h3>素材上传</h3>
					</div>
					
                     <div class="progress transition3" id="addProgress"><span id="fileName"></span>(<span id="val"></span>%)
                        <div class="bar2"><div class="value orangebar" style="width:0%;"></div></div>
                    </div><!--progress-->
                    <form id="upFrom" method="post" enctype="multipart/form-data"> 
					 <select style="width: 300px"   name="selection" id="selection">
					 	<option selected="selected" value="0">请选择版本号</option>
					 </select>
					<a id="uploadBtn" class="addBtn"><input name="file" type="file" title="上传文件" title="上传素材文件" id="upload"><i class="fa fa-cloud-upload"></i>上传素材文件</a>
					</form>
				</div>
				<!--contenttitle-->
				<table cellpadding="0" cellspacing="0" border="0" class="stdtable" id="dyntable">
					<thead>
						<tr>
							<th class="head0">素材ID</th>
							<th class="head1">文件名</th>
							<th class="head0">ossKey</th>
							<th class="head1">上传时间</th>
							<th class="head0">文件类型</th>
							<th class="head0">操作</th>
						</tr>
					</thead>
					<tfoot>
						<tr>
							<th class="head0">素材ID</th>
							<th class="head1">文件名</th>
							<th class="head0">ossKey</th>
							<th class="head1">上传时间</th>
							<th class="head0">文件类型</th>
							<th class="head0">操作</th>
						</tr>
					</tfoot>
					<tbody id="td_data">
					</tbody>
				</table>
				
				<br /><br />
				<br clear="all" />

			</div>
			<!-- centercontent -->

		</div>
		<!--bodywrapper-->
		
		<div class="alertBox positionF">
			<form class="positionF" id="editTr">
				<div class="textRight"><i class="fa fa-close closeAlert"></i></div>
				<div id="inputBox">
					<!--<label><span class="title">名称</span><input type="text" /></label>-->
				</div>
			</form>
			<div class="shadown positionF"></div>
		</div>
	</body>
	<script type="text/javascript">
	$(function(){
		$.ajax({
			type:'POST',
			url:'<%=basePath%>File/getVersionCode.do',
			dataType:'json',
			success:function(val){
				var data = val.data;
				$.each(data,function(index,comment){
					$("#selection").append('<option value="'+comment.versionCode+'">'+comment.version+'</option>') ;
				})
			},
			error:function(){
				alert("网络访问错误")
			}
		})
	}) 
	
	$('#selection').change(function(){
		getData();
	})
	
	function getData(){
		var versionCode = $('#selection').val();
		$.ajax({
			type:'POST',
			url:'<%=basePath %>/File/getFilesByVersionCode.do',
			data:{'versionCode':versionCode},
			dataType:'json',
			success:function(val){
				var data = val.data;
				html='';
				$.each(data,function(index,comment){
					html = html+'<tr class="gradeX"><td id="id">'+comment.id+'</td>'+
					'<td id="fileName">'+comment.fileName+'</td>'+
					'<td id="ossKey">'+comment.ossKey+'</td>'+
					'<td id="uploadDate">'+comment.uploadDate+'</td>'+
					'<td id="type">'+comment.type+'</td>'+
					'<td class="operate"><a class="fa fa-trash-o tdDelConfirm" title="删除" id="'+comment.id+'"></a></td></tr>';
				})
				$('#td_data').html(html);
			},
			error:function(){
				alert("网络访问错误");
			}
		})
	}
	
	$('#upload').change(function(){
		$('#fileName').text($(this).val());
		$('#addProgress').addClass('show');
		var versionCode = $('#selection').val();
		if (versionCode==""||versionCode==null||versionCode=="0"){
			alert("请选择对应版本上传！");
			window.location.reload();
			return;
		};
		var previewOptions = {
				target:'#upFrom',
                url: '<%=basePath %>/File/resourceUpload.do',
                type: 'POST',
                data:{'versionCode':versionCode},
                dataType: 'json',
                success: function (result) {
                    if (result.code=="200") {
						var i=0;
						var timer = setInterval(function(){
							if(i<100){
								i++;
								$('#addProgress .value').css('width',i+'%');
								$('#addProgress #val').text(i);
							}else{
								clearInterval(timer);
								alert(result.message);
								getData();
							}
						},3);
                    } else {
                    	alert(result.message)
                    }
                },
                iframe: false
            };
            $("#upFrom").ajaxSubmit(previewOptions);
            return false;
		})
		$('body').delegate('.tdDelConfirm','click',function(){
				var id =jQuery(this).attr("id");
				jConfirm('是否删除？', '删除操作', function(r) {
				if(r){
					 $.ajax({
						 url:'<%=basePath%>Config/del/adminResource.do',
						 data:{'id':id},
						 dataType:'JSON',
						 type:'POST',
						 success:function(data){
							 if (data.code=='200'){
								 alert(data.message);
								 getData();
							 } else {
								 alert(data.message);
								 window.location.reload();
							 }
						 },
						 error:function(){
							 alert("操作失败，请稍后再试");
							 window.location.reload();
						 }
					 })
				}else{
					
				}
			});
			return false;
		});
<%-- 		$("#save").click(function(){
			var options = {
					target:'#editTr',
	                url: '<%=basePath%>Config/member.do',
	                type: 'POST',
	                dataType: 'json',
	                success: function (result) {
	                    if (result.code=="200") {
							alert(result.message);
							window.location.reload();
	                    }
	                    else {
	                    	alert(result.message);
	                    }
	                },
	                iframe: false
	            };
	            $("#editTr").ajaxSubmit(options);
	            return false;
		}); --%>
		</script>
		<script type="text/javascript" src="<%=basePath %>js/plugins/jquery-1.7.min.js"></script>
		<script type="text/javascript" src="<%=basePath %>js/plugins/jquery-ui-1.8.16.custom.min.js"></script>
		<script type="text/javascript" src="<%=basePath %>js/plugins/jquery.cookie.js"></script>
		<script type="text/javascript" src="<%=basePath %>js/plugins/jquery.dataTables.min.js"></script>
		<script type="text/javascript" src="<%=basePath %>js/plugins/jquery.uniform.min.js"></script>
		<script type="text/javascript" src="<%=basePath %>js/custom/general.js"></script>
		<script type="text/javascript" src="<%=basePath %>js/custom/tables.js"></script>
		
		<!--弹出框js-->
		<script type="text/javascript" src="<%=basePath %>js/plugins/colorpicker.js"></script>
		<script type="text/javascript" src="<%=basePath %>js/plugins/jquery.alerts.js"></script>
		<script type="text/javascript" src="<%=basePath %>js/custom/elements.js"></script>
		<!--[if lte IE 8]><script language="javascript" type="text/javascript" src="js/plugins/excanvas.min.js"></script><![endif]-->
		<!--[if IE 9]>
    <link rel="stylesheet" media="screen" href="css/style.ie9.css"/>
<![endif]-->
		<!--[if IE 8]>
    <link rel="stylesheet" media="screen" href="css/style.ie8.css"/>
<![endif]-->
		<!--[if lt IE 9]>
	<script src="js/plugins/css3-mediaqueries.js"></script>
<![endif]-->
</html>